package testPlayer;
import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Scanner;

import player.*;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;

import board.Board;

public class testPlayerProcessor extends TestCase {
	
	@Test
	public void testPlayerRole()  {
		String data = "\n";
		InputStream stdin = System.in;
		
		try {
			System.setIn(new ByteArrayInputStream(data.getBytes()));
			Scanner scanner = new Scanner(System.in);
			System.out.println(scanner.nextLine());
		} finally {
			System.setIn(stdin);
		}
		
		PlayerDataProcessor PDP = new PlayerDataProcessor();
		Player[] player = new Player[2];
		for (int i=0; i<2; i++) {
			player[i] = new Player();
			player[i].setPlayerID((i+1));
		}
				
		PDP.playerRole(player, 2);
		
		String expected1 = "mother";
		String expected2 = "father";
		String expected3 = "grandmother";
		String expected4 = "grandfather";
		String expected5 = "son";
		String expected6 = "daughter";
		String actual = player[1].getRole();
		
		assertEquals(expected1, actual);
		assertEquals(expected2, actual);
		assertEquals(expected3, actual);
		assertEquals(expected4, actual);
		assertEquals(expected5, actual);
		assertEquals(expected6, actual);
		
	}
	
	@Test
	public void testOrderPlayer() {
		PlayerDataProcessor pdp = new PlayerDataProcessor();
		Player [] pArr = new Player[2];
		for (int i=0; i<2; i++) {
			pArr[i] = new Player();
			pArr[i].setPlayerID((i+1));
		}
		
		int[][] result = new int [2][2];
		result[0][1]=2;
		result[1][1]=4;
			
		pdp.playerOrder(pArr, 2);
		
		int expected = 1;
		assertEquals(expected, pArr[0].getPlayerID());
	}
}
